﻿using Mozhi.Abp.Core.Networks;
using Mozhi.Abp.Domain.BasicData;
using Mozhi.Abp.Domain.BasicData.Repositories;
using Mozhi.Abp.Infrastructure.RemoteRepositories;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Mozhi.Abp.Domain.Repository.BasicData.RemoteRepositories
{
    public class ProductAuxiliaryUnitRepository : RemoteRepository<ProductAuxiliaryUnit>, IProductAuxiliaryUnitRepository
    {
        public ProductAuxiliaryUnitRepository(IRemoteServiceClient remoteServiceClient) : base(remoteServiceClient, "BasicData", "/api/v1/products/auxiliary-units")
        {
        }

        public async Task<ProductAuxiliaryUnit> GetAsync(Guid productId, Guid otherUnitId)
        {
            var url = $"{_url}?productId={productId}&otherUnitId={otherUnitId}&skipCount=0&maxResultCount=1";

            var responseResult = await _remoteServiceClient.GetListAsync<ProductAuxiliaryUnit>(_serviceName, url);

            return responseResult.FirstOrDefault();
        }
    }
}
